home *** CD-ROM | disk | FTP | other *** search
/ SuperHack / SuperHack CD.bin / CODING / PASCAL / ALLSWAGS.ZIP / SWAGN-R.ZIP / NETWORK.SWG / 0031_IPX Chat Box.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1995-05-26  |  7.6 KB  |  294 lines

  1. {
  2. From: S0730076@let.rug.nl (ill)
  3.  
  4. I wrote a chatbox with one of those ipx units. Pretty standard but funny
  5. because you can send the other guy screentrashes and beeps and buzzes etc.
  6.  
  7. I dare not post it here cause Timo is gonna flame me with that standard
  8. 'don't post any binaries' file so mail me if you want it. I'll include
  9. source from the main file here, but you can't compile it without some
  10. other units I'm afraid.
  11. }
  12.  
  13. {$R+}
  14. uses ipx, crt,ill,win, novell, strings;
  15.  
  16.  
  17. const
  18.      receive_socket = $7713;
  19.      send_socket = $6613;
  20.      starty = 7;
  21.      maxy = 9;
  22.      maxlen = 77;
  23.      versie = 'Nag 0.81';
  24.  
  25. procedure abort(message:string);
  26. begin
  27.      writeln(message);
  28.      halt(1);
  29. end;
  30.  
  31. var
  32.    i                          : byte;
  33.    x,y,xx                     : word;
  34.    connection_number          : word;
  35.    network_number             : networkNumber;
  36.    network_node               : networkNode;
  37.    receive_ecb,send_ecb       : ECB;
  38.    receive_header,send_header : IPXHeader;
  39.    send_message, receive_message : MessageSTR;
  40.    done                        : boolean;
  41.    message,naam                : string;
  42.    code, station               : integer;
  43.    InStrings                   : array[1..maxy] of string[maxlen];
  44.    blinking          : boolean;
  45.  
  46.  
  47. procedure info(txt : string);
  48. begin
  49.  txt := '─'+txt +
  50. '─────────────────────────────────────────────────────────────────────────────'
  51.  writeline(copy(txt,1,78), 1, 16, black, lightgray);
  52. end;
  53. procedure writeInStrings;
  54. var q: integer;
  55.     col : word;
  56. begin
  57. col := lightgray;
  58. if blinking then col := col + blink;
  59. for q := 1 to maxy do
  60.      writeline(InStrings[q], 1, q + starty-1,col, black);
  61. end;
  62.  
  63.  
  64. procedure wipe;
  65. var q : integer;
  66. begin
  67. blinking := false;
  68. info('Your screen is being wiped');
  69. for q := 1 to maxy do
  70. begin
  71.     inStrings[q] :=
  72. '                                                                             
  73. ';
  74. writeInstrings;
  75. clrscr;
  76. x := 0;
  77. y := 1;
  78. end;
  79. end;
  80.  
  81. procedure shit(ki : keytype; var shitty : char);
  82. begin
  83.      shitty := #0;
  84.      case ki of
  85.           f1 : begin
  86.                    info('Sending BUZZ to '+paramstr(1));
  87.                    shitty := #201;
  88.               end;
  89.           f2 :   begin
  90.                      info('Sending BEEP to '+paramstr(1));
  91.                      shitty := #202;
  92.                 end;
  93.           f3 : begin
  94.                    info('Sending FLASH to '+paramstr(1));
  95.                    shitty := #203;
  96.               end;
  97.           f4: begin
  98.                   info('Calling '+paramstr(1)+' a sucker');
  99.                   shitty := #204;
  100.              end;
  101.          f5: begin
  102.                   info('Blinking your text on '+paramstr(1)+'''s screen');
  103.                   shitty := #205;
  104.              end;
  105.          f6: begin
  106.                   info('Trashing the other guy''s screen');
  107.                   shitty := #206;
  108.              end;
  109.           f10: wipe;
  110.  
  111.      end;
  112. end;
  113.  
  114. procedure flash;
  115. var q : integer;
  116. begin
  117.      info('The other guy is making your screen flash!');
  118. for q := 1 to 10 do
  119. begin
  120.      open_win(1,1,80,24, white, white);
  121.      delay(10);
  122.      close_win;
  123. end;
  124. end;
  125.  
  126. procedure init;
  127. begin
  128.   if paramcount < 1 then abort('Usage: Nag <username>');
  129.   if not IPXinstalled then abort('IPX not loaded');
  130.   connection_number := Get1stConnectionNumber(paramstr(1));
  131.   if connection_number = 0 then abort(paramstr(1) + ' not found. ');
  132.   if GetInternetAddress(connection_number,network_number,network_node)
  133.     <> 0 then abort(paramstr(1) + 'network error.');
  134.   IpxCloseSocket(send_socket);
  135.   if IPXOpenSocket(send_socket) <> 0 then abort('Socket error.');
  136.   IPXCloseSocket(receive_socket);
  137.   if IPXOpenSocket(receive_socket) <> 0 then abort('Socket error.');
  138.   done := false;
  139.   zeroecb(receive_ecb);
  140.   zeroecb(send_ecb);
  141.   y := 1;
  142.   xx := 1;
  143.   getstation(station,code);
  144.   getuser(station, naam, code);
  145.   message := naam + ' wants to nag. Type Nag '+naam;
  146.   send_message_to_username(paramstr(1), message, code);
  147.   wipe;
  148. end;
  149.  
  150. procedure funkysound;
  151. var q : integer;
  152. begin
  153.      info('Receiving birdnoise');
  154.      q := 3000;
  155.      while q > 20 do
  156.      begin
  157.           sound(q);
  158.           delay(1);
  159.           dec(q,100);
  160.      end;
  161.      nosound;
  162. end;
  163.  
  164. procedure trash;
  165. var q,x,y : word;
  166. begin
  167.      randomize;
  168.      for q := 1 to 50 do
  169.      begin
  170.          x := random(76)+2;
  171.          y := random(25-starty) + starty;
  172.          fastwrite(x,y,'#',x, y);
  173.          sound(8000);
  174.          delay(1);
  175.          nosound;
  176.      end;
  177. end;
  178.  
  179.  
  180. procedure receive_shit(i : integer);
  181. begin
  182.      case i - 200 of
  183.           1 : begin info(paramstr(1)+' is buzzing');
  184.               sound(50); delay(500); nosound; end;
  185.           2 : funkysound;
  186.           3 : flash;
  187.           4 : info('SUCKER!');
  188.           5 : blinking := true;
  189.           6 : trash;
  190.       end;
  191. end;
  192.  
  193.  
  194. procedure receive;
  195. var q : integer;
  196. begin
  197. if (receive_ecb.completion_code = 0) and (receive_ecb.in_use = 0) then
  198. begin
  199.      IPXReceive(receive_ecb, receive_header, receive_socket,
  200.             @receive_message, sizeof(receive_message));
  201.       if (receive_message < #210) and (receive_message > #200) then
  202.       begin
  203.          receive_shit(ord(receive_message[1]));
  204.          exit;
  205.       end;
  206.  
  207.       if (receive_message = chr(8)) then
  208.       begin
  209.            InStrings[y][x] := ' ';
  210.            if x > 0 then
  211.               dec(x);
  212.       end else
  213.            begin
  214.                inc(x);
  215.  
  216.               if receive_message <> chr(13)  then
  217.                     InStrings[y][x] := receive_message[1];
  218.               if (receive_message = chr(13)) or (x >= maxlen) then
  219.                begin
  220.                     inc(y);
  221.                     x := 0;
  222.                end;
  223.                if y =  maxy then
  224.                begin
  225.                     y := maxy - 1;
  226.                     x := 0;
  227.                     for q := 1 to maxy - 1 do
  228.                         instrings[q] := instrings[q+1]+
  229. '                                                                            ';
  230.                end;
  231.           end;
  232.           writeInStrings;
  233.   end;
  234. end;
  235.  
  236. procedure send;
  237. var special : boolean;
  238.     skey    : keytype;
  239.     r, sr       : char;
  240. begin
  241.      inkey(special, skey,r);
  242.      if ord(r) > 200 then
  243.         exit;
  244.      shit(skey, sr);
  245.      if (sr = #0) and (special) and (skey <> cr) and (skey <> bksp)
  246.         and (skey <> esc) then
  247.             exit;
  248.           if sr = #0 then
  249.           begin
  250.               send_message := r;
  251.               write(send_message);
  252.           end
  253.           else
  254.               send_message := sr;
  255.           if send_message = #8 then
  256.           begin
  257.                write(' ');
  258.                write(chr(8));
  259.           end;
  260.           if send_message = #13 then writeln;
  261.           IPXSend(network_number, network_node, receive_socket, @send_message,
  262.               length(send_message)+1, send_ecb,  send_header, send_socket);
  263.           if (send_message = chr(27)) or (receive_message= chr(27)) then
  264.           done := true;
  265. end;
  266.  
  267.  
  268. begin
  269.  ini_win;
  270.   open_win(1,1,80,24,black,black);
  271.   init;
  272.   receive;
  273.   x := 0;
  274.   clrscr;
  275.  open_win(1,starty,80,24, lightgray, black);
  276.  open_win(1,17,80,24, black, lightgray);
  277.  info(versie+' 1995 Willem van de Vis   Esc to quit.');
  278.  writeline('F1 buzz F2 bird F3 flash F4 sucker F5 blink F6 trash F10 clear',
  279.                2, starty-1, black, lightgray);
  280.  
  281.  textcolor(black);
  282.   repeat
  283.     receive;
  284.   IPXRelinquishControl;
  285.   if keypressed then
  286.    send;
  287.  until done;
  288.  IPXCloseSocket(send_socket);
  289.  IPXCloseSocket(receive_socket);
  290.  end_win;
  291.  writeln('no more nagging.');
  292. end.
  293.  
  294.